package com.sky.controller.admin;

import com.sky.annotation.AutoFill;
import com.sky.result.Result;
import com.sky.service.WorkSpaceService;
import com.sky.vo.BusinessDataVO;
import com.sky.vo.DishOverViewVO;
import com.sky.vo.OrderOverViewVO;
import com.sky.vo.SetmealOverViewVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.concurrent.ExecutionException;

@RestController
@Slf4j
@RequestMapping("/admin/workspace")
public class WorkSpaceController {

    @Autowired
    WorkSpaceService workSpaceService;

    // 查询菜品总览
    @GetMapping("/overviewDishes")
    public Result getOverviewDishes() {
        DishOverViewVO dishOverViewVO = workSpaceService.getOverviewDishes();
        return Result.success(dishOverViewVO);
    }

    // 查询套餐总览
    @GetMapping("/overviewSetmeals")
    public Result overviewSetmeals(){
      SetmealOverViewVO setmealOverViewVO= workSpaceService.overviewSetmeals();
      return Result.success(setmealOverViewVO);
    }

    //查询今日运营数据
    @GetMapping("/businessData")
    public Result getBusinessData() throws ExecutionException, InterruptedException {
        BusinessDataVO businessDataVO = workSpaceService.getBusinessData(LocalDate.now());
        return Result.success(businessDataVO);
    }

    // 订单管理
    @GetMapping("/overviewOrders")
    public Result overviewOrders() {
        OrderOverViewVO orderOverViewVO = workSpaceService.overviewOrders(LocalDate.now());
        return Result.success(orderOverViewVO);
    }
}
